home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
tools
/
indent.lha
/
indent
/
readme
< prev
next >
Wrap
Text File
|
1992-07-06
|
7KB
|
186 lines
---------------------------------------------------------------------
Indent is a C/C++ program formatter. It reformats the C/C++ program
in the input-file according to a long list of command line switches.
The original indent (from the University of Illinois and part of the
Berkeley Software Distribution) was only for C programs. It has since
been modified to understand C++ syntax as well.
---------------------------------------------------------------------
A short guide to indent
(for impatient users of OS/2 or MSDOS)
Assuming you have managed to unpack the distribution sources and have
compiled indent.exe:-
1. Set up an environment variable called HOME pointing at some directory
where you keep useful things. Copy indent.pro into that directory.
Alternatively put indent.pro somewhere along your DPATH or PATH.
2. If you use a brain-damaged editor which doesn't allow tabs to be set
at any interval other than 8 columns, either change the line in
indent.pro which says
-tabs 4
or simply remove it altogether.
3. Copy indent.exe to some directory on your PATH.
4. Change directory to where your messy C or C++ programs reside.
5. To clean up all the programs issue the command:
for %f in (*.c *.cpp) do indent %f
If you have an indent.pro in the current directory that will be processed
after the one found in HOME or along DPATH or PATH. This allows you to
have options unique to a project without having to specify everything.
---------------------------------------------------------------------
An even shorter guide to indent
(for impatient users of BSD-flavoured UNIX)
Read the guide for OS/2-MSDOS and make the following changes:
1. Copy indent.pro into your home directory or somewhere along your PATH,
calling it .indent.pro
5. Use a loop syntax appropriate for your shell.
If you have a .indent.pro in the current directory that will be processed
after the one found in your HOME directory or along your PATH. This allows
you to have options unique to a project without having to specify everything.
---------------------------------------------------------------------
OS/2 implementor's note
-----------------------
There seems to have been three streams of development for this program.
The original indent came from the University of Illinois where it was
apparently written in 1976. Some work was done by James Gosling and the
people at Sun Microsystems. The program became part of the BSD UNIX
distribution at some time not later than 1985. At around that time it was
ported to MSDOS by Bruce Mallett and various fixes were done by Bruce
Mallett and James Thompson. James Thompson also implemented the handling
of tabs at spacings other than 8 (surely a most worthwhile enhancement; who
programs in C with tabs set at 8 anyway?)
While all this good stuff was going on, other (unnamed) people upgraded the
original program to handle C++ syntax as well as ordinary C and apparently
fixed a few minor annoyances which were extant in the version from which
the MSDOS implementation was derived.
Then of course, the GNU project people of the Free Software Foundation have
been doing things with sources apparently derived from the BSD version.
I have not looked at the GNU version of indent. I started with the BSD C++
formatter sources from comp.misc.sources volume 21 and modified them for
compilation with Microsoft C386 under OS/2 2.0. That gave me a working
baseline version to which I made the following modifications:
1 Changed some of the file names to allow compilation with Microsoft C
version 6.00A which objects to files whose names do not conform to
MSDOS's 8.3 format.
2 Built new makefiles for OS/2 2.0 and for OS/2 1.X. (The MSDOS version
is created by post-processing the OS/2 1.X version.)
Note that when you use Makefile.1x you'll see some warning messages
concerning the truncation of variable names. You may safely ignore
them. The messages do not appear when compiling the 32-bit version.
2 Added James Thompson's tab stuff.
3 Fixed a bug which was causing //-style comments to be followed by an
extra newline or an extra space depending on context.
4 Corrected the stack overflow problem in the OS/2 1.x and MSDOS versions.
(This seems to have been independently discovered and fixed twice
previously but the sources contained no trace of the fix.)
5 Patched the manual source to reflect the new -tabs option and generated
a human-readable version.
Finally, I put the sources through the indenter to clean up the mess.
More recently still, I built the program using the IBM C Set/2 tools after
modifying the 2.0 Makefile. I also:
6 Fixed a bug notified by Steve Comen which was causing overlength //
comments to be split incorrectly.
7 Modified the profile search to include DPATH under OS/2 and to include
PATH on all platforms.
8 Modified the action of the -tabsN specifier. If N is 2 or less then
indent will not use tab characters in the output. This patch had the
side-effect of avoiding a potential divide-by-zero fault which would
have arisen if someone had said -tabs0.
Just before preparing the shar files for submission I removed all the tabs
with the command:
for %f in (*.c *.h) do indent -tabs0 %f
Now, if I have done the job properly, the current source should combine both
the BSD development streams. Furthermore, it should compile under OS/2 1.x
for OS/2 and MSDOS, under OS/2 2.0 for the 32-bit 'flat' model using either
the Microsoft C386 compiler or the IBM C Set/2 compiler and on the original
BSD UNIX platform.
I am indebted to Steve Comen and his colleagues for help with testing and
verifying the BSD compatibility and for several patches.
Now all that remains to be done is to incorporate the nicer features of this
version into the GNU one. Any volunteers?
Jon Saxton
April 1992
-------------------------------------------------------------------------
Manifest
args.c \
comment.c \
indent.c \_ Program source files
io.c /
lexi.c /
parse.c /
codes.h \
globals.h >- Header files
proto.h /
indent.1 Manual source
indent.man Manual in human-readable form
indent.def Used only when compiling
under OS/2 for OS/2 or MSDOS
indent.pro A sample profile (the one used to format
these sources). Rename to .indent.pro
for use with BSD UNIX.
Makefile.1x Makefile for compiling under OS/2 1.x.
Generates a bound 16-bit executable which
will run under OS/2 or MSDOS.
Makefile.20 Makefile for compiling under OS/2 2.0 using
the IBM C Set/2 compiler. Generates a 32-
bit executable.
Makefile.bsd Untouched. This is the original Makefile
as distributed with the BSD version.
readme This file
typedefs.os2 A collection of type names which may be
useful for programming the OS/2 kernel.
Simply add these to indent.pro or rename
typedefs.os2 to indent.pro in the current
directory.